package com.praveen.reminder;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;

public class NotificationSenderBroadcastReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context ctx, Intent intent) {
		NotificationManager mgr = (NotificationManager)ctx.getSystemService(Context.NOTIFICATION_SERVICE);
		String text = intent.getStringExtra("com.praveen.reminder.CreateNewActivity");
		int id = intent.getIntExtra("com.praveen.reminder.CreateNewActivity", 0);
		Intent notifyIntent = new Intent(ctx, NotifyMsgActivity.class);
		notifyIntent.putExtra("com.praveen.reminder.NotificationSenderBroadcastReceiver", id);
		PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, notifyIntent, PendingIntent.FLAG_CANCEL_CURRENT);
		Resources res = ctx.getResources();
		Notification note = new Notification(R.drawable.red_ball, res.getString(R.string.reminderTicker), System.currentTimeMillis());
		note.setLatestEventInfo(ctx, res.getString(R.string.reminderTitle), text, contentIntent);
		mgr.notify(id, note);
	}

}
